How to properly encode "[" and "]" in queries using Apache HttpClient?

Posted by Jason Nichols on Stack Overflow See other posts from Stack Overflow or by Jason Nichols
Published on 2010-04-12T20:28:07Z Indexed on 2010/04/12 20:32 UTC
Read the original article Hit count: 229

Filed under:
|
|

I've got a GET method that looks like the following:

 GetMethod method = new GetMethod("http://host/path/?key=[\"item\",\"item\"]");

Such a path works just fine when typed directly into a browser, but the above line when run causes an IllegalArgumentException : Invalid URI.

I've looked at using the URIUtils class, but without success. Is there a way to automatically encode this (or to add a query string onto the URL without causing HttpClient to barf?).

© Stack Overflow or respective owner

Related posts about java

Related posts about httpclient